from typing import Dict, Any, List
from pathlib import Path

from shared.config import settings


class ConvertTool:
    """MCP 转换工具定义"""
    
    @staticmethod
    def get_tools() -> List[Dict[str, Any]]:
        """获取 MCP 工具定义"""
        return [
            {
                "name": "convert_markdown_to_ppt",
                "description": "Convert Markdown content to PowerPoint presentation",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "markdown_content": {
                            "type": "string",
                            "description": "Markdown content to convert to PowerPoint"
                        },
                        "theme": {
                            "type": "string",
                            "enum": settings.supported_themes,
                            "default": settings.default_theme,
                            "description": "Presentation theme"
                        },
                        "output_filename": {
                            "type": "string",
                            "description": "Output filename (optional, will auto-generate if not provided)"
                        },
                        "image_width_ratio": {
                            "type": "number",
                            "minimum": 0.1,
                            "maximum": 1.0,
                            "default": settings.default_image_width_ratio,
                            "description": "Image width ratio (0.1 to 1.0)"
                        }
                    },
                    "required": ["markdown_content"]
                }
            },
            {
                "name": "convert_markdown_file_to_ppt",
                "description": "Convert Markdown file to PowerPoint presentation",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "file_path": {
                            "type": "string",
                            "description": "Path to the Markdown file (.md)"
                        },
                        "theme": {
                            "type": "string",
                            "enum": settings.supported_themes,
                            "default": settings.default_theme,
                            "description": "Presentation theme"
                        },
                        "output_filename": {
                            "type": "string",
                            "description": "Output filename (optional, will use input filename if not provided)"
                        },
                        "image_width_ratio": {
                            "type": "number",
                            "minimum": 0.1,
                            "maximum": 1.0,
                            "default": settings.default_image_width_ratio,
                            "description": "Image width ratio (0.1 to 1.0)"
                        }
                    },
                    "required": ["file_path"]
                }
            },
            {
                "name": "get_supported_themes",
                "description": "Get list of supported presentation themes",
                "inputSchema": {
                    "type": "object",
                    "properties": {},
                    "required": []
                }
            },
            {
                "name": "validate_markdown",
                "description": "Validate Markdown content for conversion",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "markdown_content": {
                            "type": "string",
                            "description": "Markdown content to validate"
                        }
                    },
                    "required": ["markdown_content"]
                }
            }
        ]